Easy Learning Data Structures & Algorithms Javascript: Classic data structures and algorithms in JavaScript by hu yang

Easy Learning Data Structures & Algorithms Javascript: Classic data structures and algorithms in JavaScript by hu yang

Author:hu, yang [hu, yang]
Language: eng
Format: azw3
Published: 2019-05-25T16:00:00+00:00


this.insert = function(node, newData) {

if (this.root == null) {

this.root = new Node(newData, null, null);

return;

}

var compareValue = newData - node.getData();

//Recursive left subtree, continue to find the insertion position

if (compareValue < 0) {

if (node.left == null) {

node.left = new Node(newData, null, null);

} else {

this.insert(node.left, newData);

}

} else if (compareValue > 0) {////Recursive right subtree, continue to find the insertion position

if (node.right == null) {

node.right = new Node(newData, null, null);

} else {

this.insert(node.right, newData);

}

}

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.